package com.fruit.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.lang3.StringUtils;

public class ValidateUtils {
	
	/**
	 * 手机号验证
	 * @param mobiles
	 * @return
	 */
	public static boolean phone(String phone){  
		
		
		if(StringUtils.length(phone) != 11){
			return false;
		}
		
		Pattern p = Pattern.compile("^((14[0-9])|(13[0-9])|(15[^4,\\D])|(17[^4,\\D])|(18[0-9]))\\d{8}$");  
		Matcher m = p.matcher(phone);  
		return m.matches();  
	}
	
	/**
	 * 验证密码
	 * @param pwd
	 * @return
	 * @author admin
	 * @version 2017
	 */
	public static boolean password(String pwd){
		boolean result = true;
		if(StringUtils.length(pwd) == 0 || StringUtils.length(pwd) > 32){
			result = false;
		}
		
		return result;
	}
	/**
	 * 验证短信码
	 * @param code
	 * @return
	 * @author admin
	 * @version 2017
	 */
	public static boolean code(String code){
		boolean result = true;
		if(StringUtils.length(code) != 6){
			result = false;
		}
		return result;
	}
	
	/**
	 * 验证邀请码
	 * @param invitecode
	 * @return
	 * @author admin
	 * @version 2017
	 */
	public static boolean inviteCode(String inviteCode){
		boolean result = true;
		if(StringUtils.length(inviteCode) > 20 || StringUtils.length(inviteCode) < 7){
			result = false;
		}
		return result;
	}
	
	/**
	 * 验证社会统一代码
	 * @param busLicenseNumber
	 * @return
	 * @author admin
	 * @version 2017
	 */
	public static boolean busLicenseNumber(String busLicenseNumber){
		boolean result = true;
		if(StringUtils.length(busLicenseNumber) > 18 || StringUtils.length(busLicenseNumber) ==0){
			result = false;
		}
		return result;
	}
	
	
}
